package com.zjcloud.motr.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjcloud.common.annotation.Log;
import com.zjcloud.common.core.controller.BaseController;
import com.zjcloud.common.core.domain.AjaxResult;
import com.zjcloud.common.enums.BusinessType;
import com.zjcloud.motr.domain.ZjyTextbook;
import com.zjcloud.motr.service.IZjyTextbookService;
import com.zjcloud.common.utils.poi.ExcelUtil;
import com.zjcloud.common.core.page.TableDataInfo;

/**
 * 教材信息Controller
 * 
 * @author ruoyi
 * @date 2024-08-17
 */
@RestController
@RequestMapping("/motr/textbook")
public class ZjyTextbookController extends BaseController
{
    @Autowired
    private IZjyTextbookService zjyTextbookService;

    /**
     * 查询教材信息列表
     */
    @PreAuthorize("@ss.hasPermi('motr:textbook:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZjyTextbook zjyTextbook)
    {
        startPage();
        List<ZjyTextbook> list = zjyTextbookService.selectZjyTextbookList(zjyTextbook);
        return getDataTable(list);
    }

    /**
     * 导出教材信息列表
     */
    @PreAuthorize("@ss.hasPermi('motr:textbook:export')")
    @Log(title = "教材信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZjyTextbook zjyTextbook)
    {
        List<ZjyTextbook> list = zjyTextbookService.selectZjyTextbookList(zjyTextbook);
        ExcelUtil<ZjyTextbook> util = new ExcelUtil<ZjyTextbook>(ZjyTextbook.class);
        util.exportExcel(response, list, "教材信息数据");
    }

    /**
     * 获取教材信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('motr:textbook:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zjyTextbookService.selectZjyTextbookById(id));
    }

    /**
     * 新增教材信息
     */
    @PreAuthorize("@ss.hasPermi('motr:textbook:add')")
    @Log(title = "教材信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZjyTextbook zjyTextbook)
    {
        return toAjax(zjyTextbookService.insertZjyTextbook(zjyTextbook));
    }

    /**
     * 修改教材信息
     */
    @PreAuthorize("@ss.hasPermi('motr:textbook:edit')")
    @Log(title = "教材信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZjyTextbook zjyTextbook)
    {
        return toAjax(zjyTextbookService.updateZjyTextbook(zjyTextbook));
    }

    /**
     * 删除教材信息
     */
    @PreAuthorize("@ss.hasPermi('motr:textbook:remove')")
    @Log(title = "教材信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zjyTextbookService.deleteZjyTextbookByIds(ids));
    }
}
